package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024 —03 —04
 * Time: 20:58
 */
public class ReturnOperation implements IOPeration{
    public void work(Booklist booklist) {
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in);

        System.out.println("你输入你要归还的图书");
        String name = scanner.nextLine();
        int currentSize = booklist.getUsedsize();
        for (int i = 0; i < booklist.getUsedsize(); i++) {
            Book book = booklist.getBook(i);//这个地方时次重要的去理解
            if (book.getName().equals(name)){     //这个地方时次重要的去理解
                book.setIsborrowed(false);
                System.out.println("归还成功");
                System.out.println(book);
                return;
            }
        }
        System.out.println("你归还的图书不存在！！！");



    }


}
